<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>寻找峰值</title>
</head>

<body>
  <script>

    let arr = [1, 2, 3, 4, 8, 9, 8]
    let sum = arr.reduce((a, b, c) => {
      //让上一次调用回调时的返回值也就是数组的第一个数<和其他的进行比较
      if (arr[a] < b) {
        // 返回正在处理的索引值
        return c
      }
      return a
    })
    console.log(sum)


  </script>
</body>

</html>